package ca.ioniq.shared.entity;

// Generated Jan 20, 2011 9:08:49 AM by Hibernate Tools 3.4.0.Beta1

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * User generated by hbm2java
 */
@Entity
@Table(name = "user")
@XmlRootElement(name = "user")
public class User implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Long id;
	private Address address;
	private Credential credential;
	private String userName; // this should be an email address
	private String email;
	private Byte role;
	
//	private Set<Cart> carts = new HashSet<Cart>(0);
//	private Set<Order> orders = new HashSet<Order>(0);
//	private Set<Giftcard> giftcards = new HashSet<Giftcard>(0);
//	private Set<Wishlist> wishlists = new HashSet<Wishlist>(0);
//	private Set<Message> messages = new HashSet<Message>(0);

	public User() {
	}

	public User(Address address, String userName, String email, Credential credential, Byte role) {
		this.address = address;
		this.userName = userName;
		this.email = email;
		this.credential = credential;
		this.role = role;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	@XmlElement
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "address_id")
	@XmlElement
	public Address getAddress() {
		return this.address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH } )
	@JoinColumn(name = "credential_id")
	@XmlElement	
	public Credential getCredential() {
		return credential;
	}

	public void setCredential(Credential credential) {
		this.credential = credential;
	}

	@Column(name = "user_name")
	@XmlElement
	public String getUserName() {
		return this.userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Column(name = "email")
	@XmlElement
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "role")
	@XmlElement
	public Byte getRole() {
		return this.role;
	}

	public void setRole(Byte role) {
		this.role = role;
	}

//	@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
//	public Set<Cart> getCarts() {
//		return this.carts;
//	}
//
//	public void setCarts(Set<Cart> carts) {
//		this.carts = carts;
//	}
//
//	@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
//	public Set<Order> getOrders() {
//		return this.orders;
//	}
//
//	public void setOrders(Set<Order> orders) {
//		this.orders = orders;
//	}
//
//	@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
//	public Set<Giftcard> getGiftcards() {
//		return this.giftcards;
//	}
//
//	public void setGiftcards(Set<Giftcard> giftcards) {
//		this.giftcards = giftcards;
//	}
//
//	@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
//	public Set<Wishlist> getWishlists() {
//		return this.wishlists;
//	}
//
//	public void setWishlists(Set<Wishlist> wishlists) {
//		this.wishlists = wishlists;
//	}
//
//	@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
//	public Set<Message> getMessages() {
//		return this.messages;
//	}
//
//	public void setMessages(Set<Message> messages) {
//		this.messages = messages;
//	}

}
